package com.song.invoicing.config;

import com.song.invoicing.interceptor.PermissionsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;


@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
    @Autowired
    private PermissionsInterceptor permissionsInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        ArrayList<String> excludePaths = new ArrayList<>();
        excludePaths.add("/user/login");
        excludePaths.add("/user/register");
        registry.addInterceptor(permissionsInterceptor)
                .excludePathPatterns(excludePaths);
    }
}
